package com.zhou.framework.quartz.dao;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.zhou.framework.quartz.common.QuartzExecuteTypeEnum;
import com.zhou.framework.quartz.common.QuartzLogStatusEnum;
import com.zhou.framework.util.EnumClassUtil;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.util.Objects;

/**
 * <p>
 * 
 * </p>
 *
 * @author lang.zhou
 * @since 2023-02-21
 */
@Data
@TableName("sys_quartz_log")
public class QuartzLog implements Serializable {

    private static final long serialVersionUID=1L;

    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 任务名称
     */
    private String name;

    private Integer status;

    @TableField("orgid")
    private Integer orgId;

    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date startTime;

    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date endTime;

    /**
     * 0-自动；1-手动
     */
    private Integer type;

    /**
     * 异常信息
     */
    private String log;

    @TableField(exist = false)
    private String typeName;

    @TableField(exist = false)
    private String statusName;

    @TableField(exist = false)
    private String orgName;



    public void setType(Integer type) {
        this.type = type;
        this.typeName = EnumClassUtil.getName(QuartzExecuteTypeEnum.class,type);
    }

    public void setStatus(Integer status) {
        this.status = status;
        this.statusName = EnumClassUtil.getName(QuartzLogStatusEnum.class,status);
    }
}
